package com.mydemo.design_pattern.structure_type.proxy_pattern.cglib;

import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * <p></p >
 *
 * @author liming1
 * @version $Id: CglibProxy, v1.0 2019-09-19 13:58 liming1 Exp $
 */
public class CglibProxy implements MethodInterceptor {

    private Object target;

    public CglibProxy(Object target) {
        this.target = target;
    }

    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        System.out.println("cglib dai li");
        methodProxy.invokeSuper(o,objects);
        method.invoke(target, objects);
        return null;
    }
}
